<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS 事件机制</title>
    <style>
        #parent {
            width: 200px;
            height: 200px;
            background-color: red;
        }
         #child {
            width: 100px;
            height: 100px;
            background-color: blue;
        }
    </style>
</head>
<body onclick="alert('橘子')">
    <div id="parent">
        <div id="child"></div>
    </div>
    <script>
        document.getElementById('parent').addEventListener('click',function(event) {
            console.log('parent click');
        });
        document.getElementById('child').addEventListener('click',function(event) {
            event.stopPropagation();
            console.log('child click');
        });
    </script>
</body>
</html>